home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form AddNewRelationship
- BackColor = &H00C0C0C0&
- Caption = "AddNew - Relationships"
- ClientHeight = 4305
- ClientLeft = 3180
- ClientTop = 3300
- ClientWidth = 7320
- Height = 4995
- Left = 3120
- LinkTopic = "Form1"
- ScaleHeight = 4305
- ScaleWidth = 7320
- Top = 2670
- Width = 7440
- Begin CommandButton Command2
- Caption = "AddNew to Secondary Table"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Left = 3360
- TabIndex = 1
- Top = 3240
- Width = 2895
- End
- Begin TextBox Text5
- DataField = "SecondInfo"
- DataSource = "Data2"
- Height = 405
- Left = 3240
- TabIndex = 8
- Text = "Text5"
- Top = 1920
- Width = 1335
- End
- Begin TextBox Text4
- DataField = "MasterID"
- DataSource = "Data2"
- Height = 375
- Left = 3240
- TabIndex = 7
- Text = "Text4"
- Top = 960
- Width = 1335
- End
- Begin CommandButton Command1
- Caption = "AddNew to Master Table"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 495
- Left = 240
- TabIndex = 6
- Top = 3240
- Width = 2535
- End
- Begin TextBox Text3
- DataField = "SecondaryID"
- DataSource = "Data2"
- Height = 375
- Left = 3240
- TabIndex = 5
- TabStop = 0 'False
- Text = "Text3"
- Top = 10
- Width = 1335
- End
- Begin TextBox Text2
- DataField = "MasterInfo"
- DataSource = "Data1"
- Height = 375
- Left = 120
- TabIndex = 0
- Text = "Text2"
- Top = 1920
- Width = 2055
- End
- Begin TextBox Text1
- DataField = "MasterID"
- DataSource = "Data1"
- Height = 375
- Left = 120
- TabIndex = 2
- TabStop = 0 'False
- Text = "Text1"
- Top = 960
- Width = 1215
- End
- Begin Data Data2
- Caption = "Secondary Table"
- Connect = ""
- DatabaseName = "C:\ADDNEW\addnew.mdb"
- Exclusive = 0 'False
- Height = 270
- Left = 3360
- Options = 0
- ReadOnly = 0 'False
- RecordSource = "Secondary"
- Top = 3840
- Width = 2895
- End
- Begin Data Data1
- Caption = "Master Table"
- Connect = ""
- DatabaseName = "C:\ADDNEW\addnew.mdb"
- Exclusive = 0 'False
- Height = 270
- Left = 240
- Options = 0
- ReadOnly = 0 'False
- RecordSource = "Master"
- Top = 3840
- Width = 2535
- End
- Begin Label Label5
- BackColor = &H00C0C0C0&
- Caption = "Just Information. Field Format = TEXT"
- Height = 375
- Left = 3240
- TabIndex = 11
- Top = 2400
- Width = 1935
- End
- Begin Label Label4
- BackColor = &H00C0C0C0&
- Caption = "Master Table/Secondary Table Relationship field. Field Format = Number, Long Integer"
- Height = 495
- Left = 3240
- TabIndex = 10
- Top = 1320
- Width = 3975
- End
- Begin Label Label3
- BackColor = &H00C0C0C0&
- Caption = "Secondary Table ID Field Field Format = Counter"
- Height = 375
- Left = 3240
- TabIndex = 9
- Top = 425
- Width = 2175
- End
- Begin Line Line1
- X1 = 3000
- X2 = 3000
- Y1 = 120
- Y2 = 3720
- End
- Begin Label Label2
- BackColor = &H00C0C0C0&
- Caption = "Just Information. Field Format = TEXT"
- Height = 375
- Left = 120
- TabIndex = 3
- Top = 2400
- Width = 1935
- End
- Begin Label Label1
- BackColor = &H00C0C0C0&
- Caption = "Master Table ID Field, Field Format = Counter"
- Height = 375
- Left = 120
- TabIndex = 4
- Top = 1320
- Width = 2055
- End
- Begin Menu mnuExit
- Caption = "E&xit"
- End
- Begin Menu mnuAbout
- Caption = "&About"
- End
- Sub Command1_Click ()
- 'Add a new record to the master table
- data1.Recordset.AddNew
- 'this has a TWO fold reason
- ' 1) Set the user to enter data into the first field
- ' (Text1 is avoided becuase it's a counter field)
- ' 2) Peek at the TEXT2, LOSTFOCUS Event, this updates the database
- ' Updating the database MUST be done prior to records being added
- ' into secondary table(s)
- Text2.SetFocus
- End Sub
- Sub Command2_Click ()
- 'Add a new record to the secondary table
- data2.Recordset.AddNew
- 'this records the related field number into
- 'the Secondary table's relationship field
- Text4.Text = Text1.Text
- 'make the text box that the user is going to enter
- 'data into the next available object
- Text5.SetFocus
- End Sub
- Sub Data1_Reposition ()
- 'Set up a variable for the SQL to update secondary table's movement
- ' i.e., when data1 moves to record 2, data2 moves to those related records
- Dim str1SQL As String
- 'this checks the SECONDARY table for it's related ID number
- str1SQL = "Select * FROM Secondary WHERE MasterID = " & ""
- 'this makes sure the data conbtrols don't move past the last, or first record
- 'and give you a "No Current Record" error (boo hiss)
- If data1.Recordset.EOF Then
- Beep
- data1.Recordset.MoveLast
- End If
- If data1.Recordset.BOF Then
- Beep
- data1.Recordset.MoveFirst
- End If
- 'this compares the Master table for it's related ID number
- str1SQL = str1SQL & data1.Recordset.Fields("MasterID").Value & ""
- 'this does the actual movement of data2 (Secondary table) in relation to the Master table
- data2.RecordSource = str1SQL
- data2.Refresh
- End Sub
- Sub Form_Load ()
- '---------------------------------------------
- '| This demo / example was written by |
- '| James Wj Snyder, Shattered Rose Studio |
- '| San Francisco, CA |
- '| NO warantees etc (Come on, it's free) |
- '| |
- '| Further info? Ideas? Complaints? |
- '| Compu$erve 75141, 3544 |
- '| Prodigy NAPJ88A |
- '| Internet SHATROSE@Hooked.Net |
- '| |
- '---------------------------------------------
- End Sub
- Sub Form_Unload (Cancel As Integer)
- 'the absolute exit, quit, etc etc
- End
- End Sub
- Sub mnuAbout_Click ()
- MsgBox "A quick n' dirty demo of relationships n' adding multiple to secondary table", 0, "James Wj Snyder Shattered Rose Studio"
- End Sub
- Sub mnuExit_Click ()
- Unload AddNewRelationship
- End Sub
- Sub Text1_LostFocus ()
- 'this updates the MASTER table so that the secondary
- 'table can have records added to it
- 'this is ONLY one wat to update the table, there are tons more
- ' (hey, it works for me...)
- data1.Recordset.MovePrevious
- data1.Recordset.MoveNext
- End Sub
- Sub Text2_LostFocus ()
- 'this updates the MASTER table so that the secondary
- 'table can have records added to it
- 'this is ONLY one wat to update the table, there are tons more
- ' (hey, it works for me...)
- data1.Recordset.MovePrevious
- data1.Recordset.MoveLast
- 'Make the "AddNew - Secondary Table" the next object the user uses
- ' (this is an option, but it makes peoples life easier)
- Command2.SetFocus
- End Sub
-